package com.anti.modular.bus.hydropowermeter.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.bus.hydropowermeter.param.HydropowerMeterParam;
import com.anti.modular.bus.hydropowermeter.result.HydropowerMeterResult;
import com.anti.modular.bus.hydropowermeter.service.HydropowerMeterService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 水電抄表記錄表控制器
 *
 * @author anti
 * @date 2021-05-10 21:19:36
 */
@RestController
@RequestMapping("hydropowerMeter")
public class HydropowerMeterController {

    @Resource
    private HydropowerMeterService hydropowerMeterService;

    /**
     * 查询水電抄表記錄表
     *
     * @author anti
     * @date 2021-05-10 21:19:36
     */
    @GetMapping("page")
    public Result page(PageParam pageParam, HydropowerMeterParam hydropowerMeterParam) {
        return Result.data(hydropowerMeterService.page(pageParam,hydropowerMeterParam));
    }

    /**
     * 添加水電抄表記錄表
     *
     * @author anti
     * @date 2021-05-10 21:19:36
     */
    @PostMapping("add")
    @BusinessLog(title = "水電抄表記錄表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(HydropowerMeterParam.add.class) HydropowerMeterParam hydropowerMeterParam) {
            hydropowerMeterService.add(hydropowerMeterParam);
        return Result.success("新增成功");
    }

    @PostMapping("addJzcb")
    @BusinessLog(title = "水電抄表記錄表_集中抄錶", opType = LogAnnotionOpTypeEnum.ADD)
    public Result addJzcb(@RequestBody @Validated(HydropowerMeterParam.add.class) HydropowerMeterParam hydropowerMeterParam) {
        hydropowerMeterService.addJzcb(hydropowerMeterParam);
        return Result.success("抄錶成功");
    }
    @PostMapping("addHuan")
    @BusinessLog(title = "水電抄表記錄表_集中换錶", opType = LogAnnotionOpTypeEnum.ADD)
    public Result addHuan(@RequestBody @Validated(HydropowerMeterParam.add.class) HydropowerMeterParam hydropowerMeterParam) {
        hydropowerMeterService.addHuan(hydropowerMeterParam);
        return Result.success("换錶成功");
    }

    @PostMapping("addHuanOne")
    @BusinessLog(title = "水電抄表記錄表_换錶", opType = LogAnnotionOpTypeEnum.ADD)
    public Result addHuanOne(@RequestBody HydropowerMeterResult hydropowerMeterParam) {
        hydropowerMeterService.addHuanOne(hydropowerMeterParam);
        return Result.success("换錶成功");
    }


    /**
     * 删除水電抄表記錄表
     *
     * @author anti
     * @date 2021-05-10 21:19:36
     */
    @PostMapping("delete")
    @BusinessLog(title = "水電抄表記錄表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@RequestBody @Validated(HydropowerMeterParam.delete.class) HydropowerMeterParam hydropowerMeterParam) {
            hydropowerMeterService.delete(hydropowerMeterParam);
        return Result.success("删除成功");
    }

    /**
     * 编辑水電抄表記錄表
     *
     * @author anti
     * @date 2021-05-10 21:19:36
     */
    @PostMapping("edit")
    @BusinessLog(title = "水電抄表記錄表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(HydropowerMeterParam.edit.class) HydropowerMeterParam hydropowerMeterParam) {
            hydropowerMeterService.edit(hydropowerMeterParam);
        return Result.success("修改成功");
    }

    /**
     * 查看水電抄表記錄表
     *
     * @author anti
     * @date 2021-05-10 21:19:36
     */
    @GetMapping("detail")
    public Result detail(@Validated(HydropowerMeterParam.detail.class) HydropowerMeterParam hydropowerMeterParam) {
        return Result.data(hydropowerMeterService.detail(hydropowerMeterParam));
    }

    /**
     * 水電抄表記錄表列表
     *
     * @author anti
     * @date 2021-05-10 21:19:36
     */
    @GetMapping("list")
    public Result list(HydropowerMeterParam hydropowerMeterParam) {
        return Result.data(hydropowerMeterService.list(hydropowerMeterParam));
    }

    /**
     * 水電抄表記錄表列表
     *
     * @author anti
     * @date 2021-05-10 21:19:36
     */
    @GetMapping("getSdFyListByDetail")
    public Result getSdFyListByDetail(HydropowerMeterParam hydropowerMeterParam) {
        return Result.data(hydropowerMeterService.getSdFyListByDetail(hydropowerMeterParam));
    }
    /**
     * 水電抄表記錄表列表
     *
     * @author anti
     * @date 2021-05-10 21:19:36
     */
    @GetMapping("getMeterListByBillId/{leaseId}/{costId}")
    public Result getMeterListByBillId(@PathVariable(name = "leaseId") Long leaseId, @PathVariable(name = "costId") Long costId) {
        return Result.data(hydropowerMeterService.getMeterListByBillId(leaseId,costId));
    }

    /**
     * 集中抄表
     *
     * @author anti
     * @date 2021-05-10 21:19:36
     */
    @GetMapping("getMeterListByStateIdOnJzcb/{estateId}/{costId}")
    public Result getMeterListByStateIdOnJzcb(@PathVariable(name = "estateId") Long estateId, @PathVariable(name = "costId") Long costId) {
        return Result.data(hydropowerMeterService.getMeterListByStateIdOnJzcb(estateId,costId));
    }

    @GetMapping("getMeterListByStateIdOnJzcbForOne/{leaseId}/{id}")
    public Result getMeterListByStateIdOnJzcbForOne(@PathVariable(name = "leaseId") Long leaseId,@PathVariable(name = "id") Long id) {
        return Result.data(hydropowerMeterService.getMeterListByStateIdOnJzcbForOne(leaseId,id));
    }


}
